package com.lhoverc.controller.user;

import com.lhoverc.pojo.PageBean;
import com.lhoverc.pojo.Result;
import com.lhoverc.service.announcement.AnnouncementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: LiCheng
 * @CreateTime: 2025-04-19
 * @Description:
 * @Version: 1.0
 */
@RestController
@RequestMapping("/user/announcement")
public class AnnouncementController {

    @Autowired
    private AnnouncementService announcementService;

    /**
     * 公告分页查询
     * @param page
     * @param pageSize
     * @param keyword
     * @return
     */
    @GetMapping("/getAnnouncements")
    public Result getAnnouncementList(@RequestParam Integer page,
                                       @RequestParam Integer pageSize,
                                       @RequestParam String keyword) {
        PageBean pageBean = announcementService.page(page, pageSize, keyword);
        return Result.success(pageBean);
    }

    /**
     * 获取最近的公告
     * @return
     */
    @GetMapping("/getRecentAnnouncements")
    public Result getRecentAnnouncement() {
        PageBean pageBean = announcementService.getRecentAnnouncement();
        return Result.success(pageBean);
    }
}
